#include "process.h"

const char *str ="|/-\\";

void process_v1(){
    int rate=0;
    char bar[SIZE];
    memset(bar, '\0',sizeof(bar));

    int num = strlen(str);
    while(rate <= MAX_RATE)
        {
            printf("[%-100s][%d%%][%c]\r",bar,rate,str[rate%num]);
            fflush(stdout);
            usleep(STIME);
            bar[rate++] = STYLE;
        }
    printf("\n");
}
void process_v2(int rate){
    static char bar[SIZE] = {0};
    int num = strlen(str);
    if(rate <= MAX_RATE && rate >= 0)
    {
    printf("[%-100s][%d%%][%c]\r", bar, rate, str[rate%num]);
    fflush(stdout);
    bar[rate] = STYLE;
    }
    if(rate == MAX_RATE) memset(bar, '\0', sizeof(bar));
}

